cur_site=3;
res_mat={};
%vis_resp,run_resp,blink_resp,eye_resp,fdbk_resp,blink_dark_resp,eye_dark_resp,run_dark_resp,fb_snips,pb_snips
[~,res_mat{1},res_mat{2},res_mat{3},res_mat{4},res_mat{5},res_mat{6},res_mat{7},res_mat{8},res_mat{9},res_mat{10}]=meta_get_cell_type_onset(proj_meta,cur_site);

num_tp=size(res_mat{1},2);
num_cell=size(res_mat{1},1);
sig_num=[];
for gnd=1:num_tp
    for vnd=1:num_cell
        cnt=9;
        for und=1:10
            if und<9
                cur_trace=mean(res_mat{und}{vnd,gnd},1);
                if ~isempty(cur_trace)
                    sig_num(vnd,und,gnd)=mean(cur_trace(15:20))-mean(cur_trace(5:10));
                else
                    sig_num(vnd,und,gnd)=0;
                end
            else
                for knd=1:13
                    cur_trace=mean(res_mat{und}{vnd,gnd}{knd},2)';
                    if ~isempty(cur_trace)
                        sig_num(vnd,cnt,gnd)=mean(cur_trace(20:25))-mean(cur_trace(10:15));
                        cnt=cnt+1;
                    else
                        sig_num(vnd,cnt,gnd)=0;
                        cnt=cnt+1;
                    end
                end
            end
        end
    end
end

for vnd=1:num_cell
    for tnd=1:size(sig_num,2)
        mean_mat(vnd,tnd)=mean(sig_num(vnd,tnd,:));
    end
end

cur_feat=21;
[a,b]=sort(mean_mat(:,cur_feat));
res_sorted=[];
res_sorted(:,:)=sig_num(b,cur_feat,:);
figure;plot(res_sorted,'.')
hold on
plot(mean_mat(b,cur_feat),'linewidth',2,'col','k')
figure;plot(range(res_sorted,2))

